<template>
	<div class="checkInfo">
		<div class="title" v-show="loanCheckList.length>0">贷款审核记录</div>
		<div v-for="(el , index) in loanCheckList">
			<div class="info-subtitle">记录{{index+1}}</div>
			<div v-for="(val , i) in el">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						审核人：
						<label class="text">{{val.name}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核日期：
						<label class="text">{{val.date}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核状态：
						<label class="text">{{val.status}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink" v-show="val.analysis.desc">
					<el-col class="subtitle" :span="3">客户分析</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'loanCheckAnalysis'+index + i">
						{{ val.analysis.desc }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('loanCheckAnalysis'+index+i, val.analysis)">{{ val.analysis.shrinkText}}</el-button>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink" v-show="val.check.desc">
					<el-col class="subtitle" :span="3">审核意见</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'loanCheckCheck'+index+i">
						{{ val.check.desc }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('loanCheckCheck'+index+i, val.check)">{{ val.check.shrinkText}}</el-button>
					</el-col>
				</el-row>
			</div>
		</div>
		<div class="title" v-show="dataModificationInfo.length>0">资料修改记录</div>
		<div v-for="(el,index) in dataModificationInfo">
			<div class="info-subtitle">记录{{index+1}}</div>
			<el-row class="info-row">
				<el-col :span="8" class="info-label">
					修改人：
					<label class="text">{{el.modifyPerson.person}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					修改日期：
					<label class="text">{{el.modifyPerson.date}}</label>
				</el-col>
			</el-row>
			<!-- <el-row class="info-row resultShrink">
					<el-col class="subtitle" :span="3">修改原因</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'modification'+index">
						{{ el.modifyPerson.modification.result }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('modification'+index, el.modifyPerson.modification)">{{ el.modifyPerson.modification.shrinkText}}</el-button>
					</el-col>
				</el-row> -->
			<div v-for="(val,i) in el.data">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						审核人：
						<label class="text">{{val.checkPerson}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核日期：
						<label class="text">{{val.checkDate}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核状态：
						<label class="text">{{val.checkStatus}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink">
					<el-col class="subtitle" :span="3">审核意见</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'modification'+index+i">
						{{ val.check.suggest }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('modification'+index+i, val.check)">{{ val.check.shrinkText}}</el-button>
					</el-col>
				</el-row>
			</div>
			<el-table :data="el.dateList" class="info-table" border>
				<el-table-column prop="name" label="修改项名称" width="160">
				</el-table-column>
				<el-table-column prop="newContent" label="新内容" width="310">
				</el-table-column>
				<el-table-column prop="oldContent" label="旧内容">
				</el-table-column>
			</el-table>
		</div>
		<div class="title" v-show="accommodation.length>0">通融记录</div>
		<div v-for="(el , index) in accommodation">
			<div class="info-subtitle">记录{{index+1}}</div>
			<el-row class="info-row">
				<el-col :span="8" class="info-label">
					通融发起人：
					<label class="text">{{el.sponsor.sponsorPerson}}</label>
				</el-col>
				<el-col :span="8" class="info-label">
					通融发起日期：
					<label class="text">{{el.sponsor.sponsorDate}}</label>
				</el-col>
			</el-row>
			<el-row class="info-row resultShrink">
				<el-col class="subtitle" :span="3">通融原因</el-col>
				<el-col :span="12" class="text-height text-height-shrink" :id="'accommodationReason'+index">
					{{ el.sponsor.reason.reason }}
				</el-col>
				<el-col :span="3">
					<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('accommodationReason'+index, el.sponsor.reason)">{{ el.sponsor.reason.shrinkText}}</el-button>
				</el-col>
			</el-row>
			<div v-for="(val , i) in el.check">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						审核人：
						<label class="text">{{val.checkPerson}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核日期：
						<label class="text">{{val.checkDate}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核状态：
						<label class="text">{{val.checkStatus}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink">
					<el-col class="subtitle" :span="3">审核意见</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'accommodationSuggest'+index+i">
						{{ val.suggest.suggest }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('accommodationSuggest'+index+i, val.suggest)">{{ val.suggest.shrinkText}}</el-button>
					</el-col>
				</el-row>
			</div>
		</div>
		<div class="title" v-show="reject.length>0">打款驳回记录</div>
		<div v-for="(el , index) in reject">
			<div class="info-subtitle">记录{{index+1}}</div>
			<div v-for="(val , i) in el">
				<el-row class="info-row">
					<el-col :span="8" class="info-label">
						审核人：
						<label class="text">{{val.checkPerson}}</label>
					</el-col>
					<el-col :span="8" class="info-label">
						审核日期：
						<label class="text">{{val.checkDate}}</label>
					</el-col>
				</el-row>
				<el-row class="info-row resultShrink">
					<el-col class="subtitle" :span="3">驳回原因</el-col>
					<el-col :span="12" class="text-height text-height-shrink" :id="'rejectReason'+index+i">
						{{ val.reason }}
					</el-col>
					<el-col :span="3">
						<el-button class="credit-button-text" type="text" @click="$libs.changeHeight('rejectReason'+index+i, val)">{{ val.shrinkText}}</el-button>
					</el-col>
				</el-row>
			</div>
		</div>
	</div>
</template>
<script type="text/javascript">
export default {
	name: 'checkInfo',
	data() {
		return {
			// 贷款审核记录
			loanCheckList: [],
			dataModificationInfo: [],
			accommodation: [],
			reject: []
		}
	},
	methods: {
		getInfo(_id) {
			let approvalResult = ['拒绝', '通过', '提交上级', '附加条件通过'];
			this.$http.get('/audit/tasks/' + _id).then((data) => {
				if (data.data.success) {
					let datas = data.data.data;
					// 贷款审核记录
					this.loanCheckList = [];
					$.each(datas.orderAuditApplyVOList, (i, val) => {
						let loanCheckList = [];
						$.each(val.orderAuditTaskList, (j, el) => {
							loanCheckList.push({
								name: el.approveStaffName, //审核人
								date: el.approvalTime, //审核日期
								status: el.approvalResult, //审核状态
								analysis: {
									desc: el.customerAnalysis, //客户分析
									shrink: false,
									shrinkText: '展开全部'
								},
								check: {
									desc: el.approvalRemark, //审核意见
									shrink: false,
									shrinkText: '展开全部'
								},
							});
						});
						this.loanCheckList.push(loanCheckList);
					});
					// 资料修改记录
					$.each(datas.modifyRecordOrderAuditApplyVOList, (i, val) => {
						let dataList = [],
							orderAuditTaskList = [];
						$.each(val.modifyHisVOList, (j, el) => {
							if (el.fieldAlias.indexOf('比例') == -1) {
								dataList.push({
									name: el.fieldAlias,
									newContent: el.newValue,
									oldContent: el.oldValue
								});
							} else {
								dataList.push({
									name: el.fieldAlias,
									newContent: el.newValue + '%',
									oldContent: el.oldValue + '%'
								});
							}

						});
						$.each(val.orderAuditTaskList, (j, el) => {
							orderAuditTaskList.push({

								checkPerson: el.approveStaffName, //审核人
								checkDate: el.approvalTime, //审核日期
								checkStatus: el.approvalResult, //审核状态
								check: {
									suggest: el.approvalRemark, //审核意见
									shrink: false,
									shrinkText: '展开全部'
								}
							});
						});

						this.dataModificationInfo.push({
							data: orderAuditTaskList,
							modifyPerson: {
								person: val.staffName, //修改人
								date: val.gmtCreate, //修改日期
								modification: {
									result: '', //修改原因
									shrink: false,
									shrinkText: '展开全部'
								},
							},
							dateList: dataList
						});
					});

					// 通融记录
					$.each(datas.accommodateOrderAuditApplyVOList, (i, val) => {
						let accommodation = [];
						$.each(val.orderAuditTaskList, (j, el) => {
							accommodation.push({
								checkPerson: el.approveStaffName, //审核人
								checkDate: el.approvalTime, //审核日期
								checkStatus: el.approvalResult, //审核状态
								suggest: {
									suggest: el.approvalRemark, //审核意见
									shrink: false,
									shrinkText: '展开全部'
								}
							});
						});
						this.accommodation.push({
							sponsor: {
								sponsorPerson: val.staffName, //通融发起人
								sponsorDate: val.gmtCreate, //通融发起日期
								reason: {
									reason: val.remark, //通融原因
									shrink: false,
									shrinkText: '展开全部'
								},
							},
							check: accommodation
						});
					});
					// 打款驳回记录
					$.each(datas.rejectPaymentOrderAuditApplyVOList, (i, val) => {
						let reject = [];
						$.each(val.orderAuditTaskList, (j, el) => {
							reject.push({
								checkPerson: el.approveStaffName, //审核人
								checkDate: el.approvalTime, //审核日期
								reason: el.approvalResult, //驳回原因
								shrink: false,
								shrinkText: '展开全部'
							});
						});
						this.reject.push(reject);
					});
				}
			}).catch((error) => {

			});
		}
	},
	mounted() {

	}
}

</script>
<style lang="scss" scoped>
@import '../../assets/css/site.scss';
.checkInfo {
	font-size: 14px;
	color: #475669;
	padding-top: 17px;
}

</style>
